home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / dc-0_2.lha / dc-0.2 / dc.info (.txt) < prev    next >
GNU Info File  |  1993-04-17  |  11KB  |  208 lines

  1. This is Info file dc.info, produced by Makeinfo-1.52 from the input
  2. file dc.texinfo.
  3.    This file documents DC, an arbitrary precision calculator.
  4.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1984 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided that
  12. the entire resulting derived work is distributed under the terms of a
  13. permission notice identical to this one.
  14.    Permission is granted to copy and distribute translations of this
  15. manual into another language, under the above conditions for modified
  16. versions, except that this permission notice may be stated in a
  17. translation approved by the Foundation.
  18. File: dc.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  19. * Menu:
  20. * Introduction::                Introduction
  21. * Printing Commands::           Printing Commands
  22. * Arithmetic::                  Arithmetic
  23. * Stack Control::               Stack Control
  24. * Registers::                   Registers
  25. * Parameters::                  Parameters
  26. * Strings::                     Strings
  27. * Status Inquiry::              Status Inquiry
  28. * Notes::                       Notes
  29. File: dc.info,  Node: Introduction,  Next: Printing Commands,  Prev: Top,  Up: Top
  30. Introduction
  31. ************
  32.    DC is a reverse-polish desk calculator which supports unlimited
  33. precision arithmetic.  It also allows you to define and call macros.
  34. Normally DC reads from the standard input; if any command arguments are
  35. given to it, they are filenames, and DC reads and executes the contents
  36. of the files before reading from standard input.  All output is to
  37. standard output.
  38.    To exit, use `q'.  `C-c' does not exit; it is used to abort macros
  39. that are looping, etc.  (Currently this is not true; `C-c' does exit.)
  40.    A reverse-polish calculator stores numbers on a stack.  Entering a
  41. number pushes it on the stack.  Arithmetic operations pop arguments off
  42. the stack and push the results.
  43.    To enter a number in DC, type the digits, with an optional decimal
  44. point.  Exponential notation is not supported.  To enter a negative
  45. number, begin the number with `_'.  `-' cannot be used for this, as it
  46. is a binary operator for subtraction instead.  To enter two numbers in
  47. succession, separate them with spaces or newlines.  These have no
  48. meaning as commands.
  49. File: dc.info,  Node: Printing Commands,  Next: Arithmetic,  Prev: Introduction,  Up: Top
  50. Printing Commands
  51. *****************
  52.      Prints the value on the top of the stack, without altering the
  53.      stack.  A newline is printed after the value.
  54.      Prints the value on the top of the stack, popping it off, and does
  55.      not print a newline after.
  56.      Prints the entire contents of the stack and the contents of all of
  57.      the registers, without altering anything.  This is a good command
  58.      to use if you are lost or want to figure out what the effect of
  59.      some command has been.
  60. File: dc.info,  Node: Arithmetic,  Next: Stack Control,  Prev: Printing Commands,  Up: Top
  61. Arithmetic
  62. **********
  63.      Pops two values off the stack, adds them, and pushes the result.
  64.      The precision of the result is determined only by the values of
  65.      the arguments, and is enough to be exact.
  66.      Pops two values, subtracts the first one popped from the second
  67.      one popped, and pushes the result.
  68.      Pops two values, multiplies them, and pushes the result.  The
  69.      number of fraction digits in the result is controlled by the
  70.      current precision flag (see below) and does not depend on the
  71.      values being multiplied.
  72.      Pops two values, divides the second one popped from the first one
  73.      popped, and pushes the result.  The number of fraction digits is
  74.      specified by the precision flag.
  75.      Pops two values, computes the remainder of the division that the
  76.      `/' command would do, and pushes that.  The division is done with
  77.      as many fraction digits as the precision flag specifies, and the
  78.      remainder is also computed with that many fraction digits.
  79.      Pops two values and exponentiates, using the first value popped as
  80.      the exponent and the second popped as the base.  The fraction part
  81.      of the exponent is ignored.  The precision flag specifies the
  82.      number of fraction digits in the result.
  83.      Pops one value, computes its square root, and pushes that.  The
  84.      precision flag specifies the number of fraction digits in the
  85.      result.
  86.    Most arithmetic operations are affected by the "precision flag",
  87. which you can set with the `k' command.  The default precision value is
  88. zero, which means that all arithmetic except for addition and
  89. subtraction produces integer results.
  90.    The remainder operation (`%') requires some explanation: applied to
  91. arguments `a' and `b' it produces `a - (b * (a / b))', where `a / b' is
  92. computed in the current precision.
  93. File: dc.info,  Node: Stack Control,  Next: Registers,  Prev: Arithmetic,  Up: Top
  94. Stack Control
  95. *************
  96.      Clears the stack, rendering it empty.
  97.      Duplicates the value on the top of the stack, pushing another copy
  98.      of it.  Thus, `4d*p' computes 4 squared and prints it.
  99. File: dc.info,  Node: Registers,  Next: Parameters,  Prev: Stack Control,  Up: Top
  100. Registers
  101. *********
  102.    DC provides 128 memory registers, each named by a single ASCII
  103. character.  You can store a number in a register and retrieve it later.
  104.      Pop the value off the top of the stack and store it into register
  105.      R.
  106.      Copy the value in register R, and push it onto the stack.  This
  107.      does not alter the contents of R.
  108.      Each register also contains its own stack.  The current register
  109.      value is the top of the register's stack.
  110.      Pop the value off the top of the (main) stack and push it onto the
  111.      stack of register R.  The previous value of the register becomes
  112.      inaccessible.
  113.      Pop the value off the top of register R's stack and push it onto
  114.      the main stack.  The previous value in register R's stack, if any,
  115.      is now accessible via the `lR' command.
  116.    The `f' command prints a list of all registers that have contents
  117. stored in them, together with their contents.  Only the current
  118. contents of each register (the top of its stack) is printed.
  119. File: dc.info,  Node: Parameters,  Next: Strings,  Prev: Registers,  Up: Top
  120. Parameters
  121. **********
  122.    DC has three parameters that control its operation: the precision,
  123. the input radix, and the output radix.  The precision specifies the
  124. number of fraction digits to keep in the result of most arithmetic
  125. operations.  The input radix controls the interpretation of numbers
  126. typed in; *all* numbers typed in use this radix.  The output radix is
  127. used for printing numbers.
  128.    The input and output radices are separate parameters; you can make
  129. them unequal, which can be useful or confusing.  Each radix must be
  130. between 2 and 36 inclusive.  The precision must be zero or greater.
  131. The precision is always measured in decimal digits, regardless of the
  132. current input or output radix.
  133.      Pops the value off the top of the stack and uses it to set the
  134.      input radix.
  135.      Similarly set the output radix and the precision.
  136.      Pushes the current input radix on the stack.
  137.      Similarly push the current output radix and the current precision.
  138. File: dc.info,  Node: Strings,  Next: Status Inquiry,  Prev: Parameters,  Up: Top
  139. Strings
  140. *******
  141.    DC can operate on strings as well as on numbers.  The only things you
  142. can do with strings are print them and execute them as macros (which
  143. means that the contents of the string are processed as DC commands).
  144. Both registers and the stack can hold strings, and DC always knows
  145. whether any given object is a string or a number.  Some commands such as
  146. arithmetic operations demand numbers as arguments and print errors if
  147. given strings.  Other commands can accept either a number or a string;
  148. for example, the `p' command can accept either and prints the object
  149. according to its type.
  150. `[CHARACTERS]'
  151.      Makes a string containing CHARACTERS and pushes it on the stack.
  152.      For example, `[foo]P' prints the characters `foo' (with no
  153.      newline).
  154.      Pops a value off the stack and executes it as a macro.  Normally
  155.      it should be a string; if it is a number, it is simply pushed back
  156.      onto the stack.  For example, `[1p]x' executes the macro `1p',
  157.      which pushes 1 on the stack and prints `1' on a separate line.
  158.      Macros are most often stored in registers; `[1p]sa' stores a macro
  159.      to print `1' into register `a', and `lax' invokes the macro.
  160.      Pops two values off the stack and compares them assuming they are
  161.      numbers, executing the contents of register R as a macro if the
  162.      original top-of-stack is greater.  Thus, `1 2>a' will invoke
  163.      register `a''s contents and `2 1>a' will not.
  164.      Similar but invokes the macro if the original top-of-stack is less.
  165.      Similar but invokes the macro if the two numbers popped are equal.
  166.      This can also be validly used to compare two strings for equality.
  167.      Reads a line from the terminal and executes it.  This command
  168.      allows a macro to request input from the user.
  169.      During the execution of a macro, this comand does not exit DC.
  170.      Instead, it exits from that macro and also from the macro which
  171.      invoked it (if any).
  172.      Pops a value off the stack and uses it as a count of levels of
  173.      macro execution to be exited.  Thus, `3Q' exits three levels.
  174. File: dc.info,  Node: Status Inquiry,  Next: Notes,  Prev: Strings,  Up: Top
  175. Status Inquiry
  176. **************
  177.      Pops a value off the stack, calculates the number of digits it has
  178.      (or number of characters, if it is a string) and pushes that
  179.      number.
  180.      Pops a value off the stack, calculates the number of fraction
  181.      digits it has, and pushes that number.  For a string, the value
  182.      pushed is -1.
  183.      Pushes the current stack depth; the number of objects on the stack
  184.      before the execution of the `z' command.
  185.      Pushes the current value of the input radix.
  186.      Pushes the current value of the output radix.
  187.      Pushes the current value of the precision.
  188. File: dc.info,  Node: Notes,  Prev: Status Inquiry,  Up: Top
  189. Notes
  190. *****
  191.    The `:' and `;' commands of the Unix DC program are not supported,
  192. as the documentation does not say what they do.  The `!' command is not
  193. supported, but will be supported as soon as a library for executing a
  194. line as a command exists.
  195. Tag Table:
  196. Node: Top
  197. Node: Introduction
  198. Node: Printing Commands
  199. Node: Arithmetic
  200. Node: Stack Control
  201. Node: Registers
  202. Node: Parameters
  203. Node: Strings
  204. Node: Status Inquiry
  205. Node: Notes
  206. 10571
  207. End Tag Table
  208.